package com.example.royalchef.adaper;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.royalchef.R;
import com.example.royalchef.base.BaseRecyclerViewAdapter;
import com.example.royalchef.base.BaseRecyclerViewHolder;
import com.example.royalchef.bean.Share;
import com.example.royalchef.utils.UIUtils;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;

/**
 * author: Administrator
 * created on: 2017/6/28 23:15
 * description:
 */

public class PushAdapter extends BaseRecyclerViewAdapter<Share.Push> {

    public PushAdapter(ArrayList<Share.Push> info, Context context, int layoutId) {
        super(info, context, layoutId);
    }

    @Override
    public void convert(BaseRecyclerViewHolder holder, Share.Push push, int position, Context context) {
        ImageView ivPicture = (ImageView) holder.getView(R.id.iv_push_item_picture);
        TextView tvTitle = (TextView) holder.getView(R.id.tv_push_item_title);
        TextView tvContent = (TextView) holder.getView(R.id.tv_push_item_content);
        TextView tvTime = (TextView) holder.getView(R.id.tv_push_item_time);
        ImageView ivNew = (ImageView) holder.getView(R.id.iv_push_item_new);
        Picasso.with(context)
                .load(push.cover)
                .resize(UIUtils.dip2px(150), UIUtils.dip2px(120))
                .centerCrop()
                .placeholder(R.mipmap.friends_sends_pictures_no)
                .config(Bitmap.Config.RGB_565)
                .into(ivPicture);
        tvTitle.setText(push.title);
        tvContent.setText(push.content);
        tvTime.setText(push.createdAt);
        ivNew.setVisibility(View.VISIBLE);


    }
}
